package com.design.patterns.list.composite;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author Wangzhiwen
 */
public class CompositeClient {

    public static void main(String[] args) {
        // 顶层接口实现声明
        OrganizationComponent university = new University("武汉大学","湖北省武汉市重点大学");

        // 子节点声明
        OrganizationComponent computersCollege = new College("计算机学院","武汉大学的重点院系");
        OrganizationComponent artCollege = new College("艺术学院","武汉大学的艺术");

        OrganizationComponent  softwareEngineering = new Department("软件工程专业","武汉大学计算机学院软件工程");
        OrganizationComponent networkSecurity = new Department("网络安全专业","武汉大学计算机学院网络安全");

        OrganizationComponent music = new Department("音乐系","武汉大学艺术学院音乐系");
        OrganizationComponent canvas = new Department("油画系","武汉大学艺术学院油画系");

        // 节点的管理
        computersCollege.add(softwareEngineering);
        computersCollege.add(networkSecurity);

        artCollege.add(music);
        artCollege.add(canvas);

        university.add(computersCollege);
        university.add(artCollege);

        List<OrganizationComponent> child = university.getChild();
        university.operation();

        // JDK 中的运用 HashMap
        Map<String,String> map = new HashMap<>();
        map.put("leaf","1");

        Map<String,String> composite = new HashMap<>();
        composite.put("composite","2");
        composite.put("composite2","2");

        // 组合
        map.putAll(composite);

        System.out.println(map);
    }

}
